
package com.googlecode.mvndroid;

import com.googlecode.mvndroid.tools.DxTool;
import java.util.ArrayList;
import java.util.List;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;


/**
 * @goal dx
 * @description Convert project's .class files into .dex files.
 *
 * @author <a href="mailto:1.024e3@gmail.com">Bartosz Duzy</a>
 */

public class Dx_dexMojo extends AndroidMojo{

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {

        ProcessBuilder processBuilder = new ProcessBuilder();
        DxTool tool = new DxTool(this);
        List<String> parameters = new ArrayList<String>();

        getLog().info("Converting compiled files and external libraries into "+getDexFile().getAbsolutePath()+"...");

        parameters.add("--dex");
        parameters.add("--output="+getDexFile().getAbsolutePath());
        parameters.add(getOutDirClasses().getAbsolutePath());
        tool.setParameters(parameters);
        
        tool.execute(processBuilder);
     
    }

}
